/*
const rand = () =>
Array.from({ length: 10 }, () => Math.floor(Math.random() * 100));

let data = rand();

function addData(chart, data) {
  chart.data.datasets.forEach(dataset => {
    let data = dataset.data;
    const first = data.shift();
    data.push(first);
    dataset.data = data;
  });

  chart.update();
}
*/

var ctx = document.getElementById("myChartold").getContext("2d");

var val =   $('#search-input').val();

var selectedValue = $('#sel').val();

$.post('/sysadmin/block/getJylist_old',function(data){
  var myChartold = new Chart(ctx, {
    type: 'line',
    data: {
      labels:  Array.from({ length: 24 }, (_, i) => i + 1).map(day => `${day}时`),
      datasets: [{
        label: '交易数',
        data: data,
        fill: false,
        borderColor: 'rgb(75, 192, 192)',
        tension: 0.1
      }]
    },
    options: {
      responsive: true,
      scales: {
        y: {
          min:0,
          beginAtZero: true
        }
      }
    }
  });})


function addData(myChartold){
  $.post('/sysadmin/block/getJylist_old',function(data){
    myChartold= new Chart(ctx, {
      type: 'line',
      data: {
        labels:  Array.from({ length: 24 }, (_, i) => i + 1).map(day => `${day}时`),
        datasets: [{
          label: '交易数',
          data: data,
          fill: false,
          borderColor: 'rgb(75, 192, 192)',
          tension: 0.1
        }]
      },
      options: {
        responsive: true,
        scales: {
          y: {
            min:0,
            beginAtZero: true
          }
        }
      }
    });})
}




setInterval(() => addData(myChartold), 5000);